package com.yysoft.interceptor;

import java.util.Map;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

public class LoginInterceptor extends AbstractInterceptor {

	@Override
	public String intercept(ActionInvocation arg0) throws Exception {
		Map<String, Object> session = ActionContext.getContext().getSession();  
        String user = (String)session.get("user");  
        if(user != null && "bing".equals(user)){  
            return arg0.invoke();  
        }else{  
            session.put("error", "your user or pwd is error, please login again...");  
            return Action.LOGIN;  
        }  
	}

}
